<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>用户注册</title>
</head>
<body>
	<form action="xx.do" method="post">
		用户名:<input type="text" name="username" value="liu"/> 
		密码：<input type="password" name="password" value="hao"/> 
		<input type="button" id="btn01" value="注册"/>
	</form>
</body>

 <script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery-1.4.4.js" ></script>
<script>
		$(function(){
			$('#btn01').click(function(){
				var username=$('inupt[name="username"]').val();
				var password=$('inupt[name="password"]').val();
				//2发送ajax请求
				var url="${pageContext.request.contextPath}/user?method=register";
				
				//{'xx':'liu','yy':'hao'}
				var data={
						
					'username':username,
					'password':password,
				};
				//data是后台返回的数据
				$.post(url,data,function(data){
					/* if(counter==1){
						//插入成功，跳转到成功页面
						window.location.href="${pageContext.request.contextPath}/user/success.jsp";
					}else{
						//插入成功，跳转到成功页面
					} */
					
					
					
				},'json');
				
			});
		});

</script>




</html>